package com.epam.events;

import javax.enterprise.event.Observes;
import javax.inject.Inject;

import com.epam.entity.Request;
import com.epam.utils.mail.HotMail;
import com.epam.utils.mail.Mail;

public class MailSender {

	@Inject @HotMail
	private Mail mail; 
	
	public void sendCreated(@Observes @Notifier(Notifications.CREATED) Request request) {
		mail.setMessage("created");
		mail.setRequest(request);
		Thread t = new Thread(mail);
		t.start();
	}

	public void sendApproved(@Observes @Notifier(Notifications.APPROVED) Request request) {
		mail.setMessage("approved");
		mail.setRequest(request);
		Thread t = new Thread(mail);
		t.start();
	}

	public void sendCancelled(@Observes @Notifier(Notifications.CANCELLED) Request request) {
		mail.setMessage("cancelled");
		mail.setRequest(request);
		Thread t = new Thread(mail);
		t.start();
	}

	public void sendClose(@Observes @Notifier(Notifications.CLOSED) Request request) {
		mail.setMessage("closed");
		mail.setRequest(request);
		Thread t = new Thread(mail);
		t.start();
	}

}